package com.globalwave.system.entity;


import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
//import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;

import com.globalwave.base.BaseEntity;
import com.globalwave.base.annotations.Comparison;
import com.globalwave.common.C;


/**
 *@Transient
 * @author Virgil.Chan
 */
@Entity
@Table(name = "SYS_USER")
public class User extends BaseEntity {

	public final static String STATUS_LOCk = "L" ;
    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="increment")
    @GenericGenerator(name="user_id_seq", strategy = "increment")
    @Column(name="id")
	private Long user_id  ;
    @Comparison(operator=Comparison.EQ)
    private String login_id ;
    private String password_ ;
    private String name_ ;
    private String email_ ;
    //private String region_ ;
    private String type_ ;
    private String status_ ;
    private String desc_ ;
    private String shop_code ;
    private String region_code ;
    private Short lock_Count ;

    @Transient
    private String old_password ;
    
    public User() {
    }
    
    public User(Long id) {
        this.user_id = id ;
    }
    
    public String getDesc_() {
        return desc_;
    }
    public void setDesc_(String desc_) {
        this.desc_ = desc_;
    }
    public String getEmail_() {
        return email_;
    }
    public void setEmail_(String email_) {
        this.email_ = email_;
    }
    public String getLogin_id() {
    	if (login_id == null) {
    		return null ;
    	}
    	if (C.EMPTY_STRING.equals(login_id)) {
    		return null ;
    	}
        return login_id.toUpperCase();
    }
    public void setLogin_id(String login_id) {
        this.login_id = login_id;
    }
    public String getName_() {
        return name_;
    }
    public void setName_(String name_) {
        this.name_ = name_;
    }
    public String getPassword_() {
        return password_;
    }
    public void setPassword_(String password_) {
        this.password_ = password_;
    }
    public String getStatus_() {
        return status_;
    }
    public void setStatus_(String status_) {
        this.status_ = status_;
    }
    
    public Long getUser_id() {
        return user_id;
    }
    public void setUser_id(Long user_id) {
        this.user_id = user_id;
    }
  
    public boolean isLock() {
    	return STATUS_LOCk.equals(status_) ;
    }

	public String getShop_code() {
		return shop_code;
	}

	public void setShop_code(String shop_code) {
		this.shop_code = shop_code;
	}

	public String getRegion_code() {
		return region_code;
	}

	public void setRegion_code(String region_code) {
		this.region_code = region_code;
	}


	/**
	 * 密码输入错误一次，将+1，输入正确后，置0，累计达3次，即锁定用户，禁止任何操作
	 */
	public Short getLock_Count() {
		return lock_Count;
	}

	public void setLock_Count(Short lock_Count) {
		this.lock_Count = lock_Count;
	}

	public String getType_() {
		return type_;
	}

	public void setType_(String type_) {
		this.type_ = type_;
	}

	public String getOld_password() {
		return old_password;
	}

	public void setOld_password(String old_password) {
		this.old_password = old_password;
	}
}
